home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 828 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.2 KB

  1. Path: crl.crl.com!not-for-mail
  2. From: bobfry@crl.com (Robert Fry)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: warning: possibly incorrect assignment
  5. Date: 9 Jan 1996 09:04:42 -0800
  6. Organization: CRL Dialup Internet Access
  7. Message-ID: <4cu77a$c8i@crl.crl.com>
  8. References: <Pine.OSF.3.91.960109091920.6447A-100000@io.UWinnipeg.ca>
  9. NNTP-Posting-Host: crl.com
  10.  
  11. Bill Simpson <wsimpson@uwinnipeg.ca> writes:
  12.  
  13. >I get the above warning when I compile code using the following
  14. >function.  It flags the **** line.
  15.  
  16. <snipping everything but the offending line>
  17.  
  18. >****        while(fp=fopen(file_name,"r"))
  19.  
  20. >How can I write this code so the compiler does not issue this warning?
  21. >Please don't suggest I just tell the compiler to shut up.  In general
  22. >the warnings are useful.  I do not want to just ignore the warning either.
  23. >I have the FAQ and haven't seen this discussed.
  24.  
  25. The compiler is warning you that 'while' statements are normally true or 
  26. false, and you might be accidentally doing an assignment where you want 
  27. to do a comparison. The code is perfectly legal, if not as clear as possible.
  28.  
  29. The only way I can think of to eliminate the warning is to change the 
  30. line to two lines:
  31.     fp = fopen( file_name, "r");
  32.     while ( fp)
  33.  
  34. Hope this helps!
  35.   Bob
  36.